package com.uyaer.magic.common
{
	import flash.net.SharedObject;

	public class Config
	{
		private static const PLATFORM_WEB:int = -1;
		private static const PLATFORM_MOB:int = 1;
		private static const PLATFORM_ANDROID:int = 2;
		private static const PLATFORM_IOS:int = 3;
		
		
		public static var platform:int = PLATFORM_MOB;
		
		public static var debug:Boolean = false;
		private static var _MUSIC:Boolean = true;
		
		
		public static function get isMobile():Boolean{
			if(platform == PLATFORM_IOS || platform == PLATFORM_ANDROID || platform == PLATFORM_MOB){
				return true;
			}
			return false;
		}
		
		/**
		 *从文件中读取配置 
		 * 
		 */		
		public static function read():void{
			var shared:SharedObject = SharedObject.getLocal("config");
			var data:Object = shared.data.config;
			if(data){
				_MUSIC = data.music;
			}else{
				_MUSIC = true;
			}
		}
		
		/**
		 *保存配置
		 * 
		 */		
		public static function save():void{
			var data:Object = new Object();
			data.music = _MUSIC;
			var shared:SharedObject = SharedObject.getLocal("config");
			shared.data.config = data;
		}

		/**
		 * 是否播放音乐
		 */
		public static function get MUSIC():Boolean{
			return _MUSIC;
		}

		/**
		 * @private
		 */
		public static function set MUSIC(value:Boolean):void{
			_MUSIC = value;
			save();
		}

	}
}